package Cookie;

import pojo.User;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class loginServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        if("cjh1234".equals(username)){
            if("123456".equals(password)){
                     req.getSession().setAttribute("user",new User(null,username,password,null));
                Object user = req.getSession().getAttribute("user");
                System.out.println(user);
                System.out.println(user);
            }else {
                System.out.println("密码错误");
            }
        }else{
            System.out.println("用户名错误");
        }
    }
}
